package com.doyens.gmall.product.controller;

import com.doyens.gmall.common.result.Result;
import com.doyens.gmall.product.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/admin/product")
public class TestController {

    @Autowired
    private TestService testService;

    @GetMapping("test/testLock")
    public void testLock(){
        testService.testLock();
    }
//读锁
    @GetMapping("read")
    public Result read(){
       String msg = testService.readLock();
        return Result.ok(msg);
    }
    //写锁
    @GetMapping("write")
    public Result write(){
        String msg = testService.writeLock();
        return Result.ok(msg);
    }
}
